From 52553c981e21bfe1724b20718a69517ab3dec565 Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Wed, 14 Oct 2015 23:08:29 +0300 Subject: [PATCH] Wrap `cargo run` `ProcessError` in `Human` if the exit code is non-zero --- src/bin/run.rs | 7 ++----- tests/test_cargo_run.rs | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/bin/run.rs b/src/bin/run.rs index 838ac4655..d765967dd 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -1,5 +1,5 @@ use cargo::ops; -use cargo::util::{CliResult, CliError, Config, human}; +use cargo::util::{CliResult, CliError, Config, Human}; use cargo::util::important_paths::{find_root_manifest_for_cwd}; #[derive(RustcDecodable)] @@ -92,10 +92,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { None => Ok(None), Some(err) => { Err(match err.exit.as_ref().and_then(|e| e.code()) { - Some(code) => { - let desc = format!("Process finished with exit status {}", code); - CliError::from_boxed(human(desc), code) - } + Some(code) => CliError::from_error(Human(err), code), None => CliError::from_error(err, 101), }) } diff --git a/tests/test_cargo_run.rs b/tests/test_cargo_run.rs index f2dab301c..11a9d9311 100644 --- a/tests/test_cargo_run.rs +++ b/tests/test_cargo_run.rs @@ -104,7 +104,7 @@ test!(exit_code { assert_that(p.cargo_process("run"), execs().with_status(2) .with_stderr(&format!("\ -Process finished with exit status 2 +Process didn't exit successfully: `target[..]foo[..]` (exit code: 2) ", ))); }); @@ -124,7 +124,7 @@ test!(exit_code_verbose { assert_that(p.cargo_process("run").arg("-v"), execs().with_status(2) .with_stderr(&format!("\ -Process finished with exit status 2 +Process didn't exit successfully: `target[..]foo[..]` (exit code: 2) ", ))); }); -- 2.30.2